05. Project Solution
Project Solution
In the next section, we are providing a potential solution to the code optimization project. Each file contains comments noting what changes have been made to make the code run faster.
We suggest waiting to look at the solution until after you've tried optimizing the code yourself - see if you can do even better!
Potential Results
Here are some potential results between Andy's code, another Udacian's optimized code, as well as both using the -O3
flag at compile time.
Code | Sum of Runtimes |
---|---|
Andy's original | ~350 ms |
Udacian's optimized | ~135 ms |
Andy's with -O3 | ~70 ms |
Udacian's with -O3 | ~20 ms |
Optimizing your code, as well as using the appropriate compiler flags, can make a huge difference. Note that the most optimized result above takes only 6% of the time to run as Andy's original code.